#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int n, x, k;
    cin >> n >> x >> k;
    int cnt = 0, p = 0, tt = k;    
    string s;
    cin >> s;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'L') cnt--;
        else cnt++;
        if(-cnt == x) {
            k -= (i + 1);
            if(k < 0) {
                cout << 0 << endl;
                return;
            }
            break;
        }
    }
    if(tt == k) {
        cout << 0 << endl;
        return;
    }
    cnt = 0;
    for(int i = 0; i < n; i++) {
        if(s[i] == 'L') cnt--;
        else cnt++;
        if(i && cnt == 0) {
            p = i + 1;
            break;
        }
    }
    if(p == 0) {
        cout << 1 << endl;
        return;
    }else{
        cout << 1 + k / p << endl;
    }
}

signed main() {
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}